var chargeIndexCtrl = myApp.controller('chargeIndexCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
	$rootScope.firstType = Tools.permissionList[3].permissionId;
	$rootScope.secondType = Tools.permissionList[3].sonPermission[0].permissionId;
	// 初始化
	function init() {
		$(document).ready(function() {
			setEchart1();
			setEchart2();
			setEchart3();
		});
	}
	init();

	// 折线图-收入确认
	function setEchart1() {
		var echart = document.getElementById('echart1');
		var myChart = echarts.init(echart);
		var option = {
		    tooltip: {
		        trigger: 'axis'
		    },
		    legend: {
		        data:['收费','退费']
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    // toolbox: {
		    //     feature: {
		    //         saveAsImage: {}
		    //     }
		    // },
		    xAxis: {
		        type: 'category',
		        boundaryGap: false,
		        data: ['201611','201712','201701','201702']
		    },
		    yAxis: {
		        type: 'value'
		    },
		    series: [
		        {
		            name:'收费',
		            type:'line',
		            data:[23, 12, 41, 34]
		        },
		        {
		            name:'退费',
		            type:'line',
		            data:[12, 22, 21, 1]
		        }
		    ]
		};
		myChart.setOption(option);
	}
	// 折线图-现金流-每月
	function setEchart2 () {
		var echart = document.getElementById('echart2');
		var myChart = echarts.init(echart);
		var option = {
		    tooltip: {
		        trigger: 'axis'
		    },
		    legend: {
		        data:['流入','流出','回款目标']
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    // toolbox: {
		    //     feature: {
		    //         saveAsImage: {}
		    //     }
		    // },
		    xAxis: {
		        type: 'category',
		        boundaryGap: false,
		        data: ['201611','201712','201701','201702']
		    },
		    yAxis: {
		        type: 'value'
		    },
		    series: [
		        {
		            name:'流入',
		            type:'line',
		            data:[120, 132, 101, 134]
		        },
		        {
		            name:'流出',
		            type:'line',
		            data:[220, 182, 191, 234]
		        },
		        {
		            name:'回款目标',
		            type:'line',
		            data:[150, 232, 201, 154]
		        }
		    ]
		};
		myChart.setOption(option);
	}

	// 折线图-现金流-每日
	function setEchart3 () {
		var echart = document.getElementById('echart3');
		var myChart = echarts.init(echart);
		var option = {
		    tooltip: {
		        trigger: 'axis'
		    },
		    legend: {
		        data:['流入','流出','回款目标']
		    },
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    // toolbox: {
		    //     feature: {
		    //         saveAsImage: {}
		    //     }
		    // },
		    xAxis: {
		        type: 'category',
		        // boundaryGap: false,
		        data: ['0时','4时','8时','12时','16时','20时']
		    },
		    yAxis: {
		        type: 'value'
		    },
		    series: [
		        {
		            name:'流入',
		            type:'bar',
		            data:[120, 132, 101, 134, 168, 152]
		        },
		        {
		            name:'流出',
		            type:'bar',
		            data:[220, 182, 191, 234, 156, 231]
		        },
		        {
		            name:'回款目标',
		            type:'bar',
		            data:[150, 232, 201, 154, 123, 432]
		        }
		    ]
		};
		myChart.setOption(option);
	}
}]);